<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="<%=basePath %>js/jquery-1.9.0.js"></script>
<script type="text/javascript">


	//登录
	function login() {
		//登录名
		var loginname_ = $.trim($("#loginname").val());
		//密码
		var password_ = $.trim($("#password").val());
		
		//验证码
		var verificationCode_ = $.trim($("#verificationCode").val());
		
		
		//判断用户名密码是否为空
		if(loginname_==""||password_==""||verificationCode_==""){
			alert("登录名名和密码以及验证码不能为空!");
			//如果为空,则不继续执行
			return ;
		} 
		
		$.ajax({
			type : "POST",
			url : "login",
			data :  {"loginname":loginname_,"password":password_,"verificationCode":verificationCode_}, 
			success : function(result) {
				if(result.success){
					alert("跳转页面")
					location.href="<%=basePath%>user/tousercenter";
				}else{
					alert("用户名或密码不正确!")
				}
			},
			error : function(error) {
				alert("error")
			}

		});
	}
	
	//跳转到注册页面
	function toregist() {
		location.href="<%=basePath%>user/toregist";

	}
</script>
<title>login</title>
</head>
<body>
		用户名:<input type="text" id="loginname" name="loginname" placeholder="请输入手机号或邮箱" />
		<br />
		密码:<input type="password" id="password" name="password" placeholder="请输入密码" />
		<br />
		验证码:<input type="text" id="verificationCode" name="verificationCode" placeholder="请输入验证码" />
		<br />
			<button id="loginbtn" name="loginbtn" onclick="login()">登录</button>
			<button id="toregistbtn" name="toregistbtn" onclick="toregist()">注册</button>
</body>
</html>